home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / nghelp.zip / HELP_VAR.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-27  |  5KB  |  246 lines

  1. {$A+,B-,E+,F-,I-,N-,O-,R-,V-}
  2. {$UNDEF DEBUG}
  3. {$IFDEF DEBUG} {$D+,L+,S+} {$ELSE} {$D-,L-,S-} {$ENDIF}
  4. Unit Help_Var;
  5.  
  6. Interface
  7.  
  8. Uses YNSystem,YNDos,YNCrt,Cursor,FastScr,Window,NG,StrInt,SwapVars;
  9.  
  10. Const HelpName  = 'NGHelp v3.01';
  11.       Copyright = HelpName+', Copyright (C) 1991-1994 by Yvo Nelemans';
  12.       CFGFName  = 'NGHELP.CFG';
  13.       Signature = 'NGHELP3.01';
  14.  
  15. Type CFGRec = Record
  16.       Color      : Boolean;
  17.       AutoLookUp : Boolean;
  18.       BigScreen  : Boolean;
  19.       NGPath     : String[79];
  20.       NGName     : String[12];
  21.      End;
  22.  
  23. Var OrginalScr    : SaveScrPtr;
  24.     CursorShape   : CursorShapeOBJ;
  25.  
  26.     UpdateScreen  : Boolean; {Build screen from nothing}
  27.  
  28.     X1_NG,Y1_NG,
  29.     X2_NG,Y2_NG   : Byte; {Coordinaten van NGCL window}
  30.     WindowC_NG    : Byte; {Color of window for NGCL}
  31.     WindowH_NG    : Byte; {HiColor of window for NGCL}
  32.     MenuC_NG      : Byte;
  33.     BoldFase      : Byte;
  34.     UnderLine     : Byte;
  35.     Reverse       : Byte;
  36.  
  37.     Default       : CFGRec;
  38.  
  39.     Key           : Char;
  40.     Extended      : Boolean;
  41.  
  42.     NoGuide       : Boolean;
  43.     Quit          : Boolean; {End this session of Help}
  44.  
  45.     SearchStr     : String[30];
  46.  
  47.     AskWindow     : AskOBJ;
  48.  
  49.     XPosition,
  50.     YPosition     : Byte;
  51.     CursorSize    : Word;
  52.  
  53.     FirstToDisk   : Pointer;
  54.     SwpPath       : String[79];
  55.  
  56.  
  57. Procedure Read_CFG;
  58. Procedure Write_CFG;
  59.  
  60. Procedure SaveAll;
  61. Procedure RestoreAll;
  62.  
  63. Procedure HotKeys;
  64. Procedure ChangeHotKey;
  65.  
  66. Procedure UnInstallHelp;
  67.  
  68. Implementation
  69.  
  70.  
  71. Function CFGPath : Str79;
  72. Var D : DirStr;
  73.     N : NameStr;
  74.     E : ExtStr;
  75. Begin
  76.  FSplit(ParamStr(0),D,N,E);
  77.  if (Length(D)>3) And (D[Length(D)]<>'\') then D := D + '\';
  78.  D := D + CFGFName;
  79.  CFGPath := D;
  80. End;
  81.  
  82. Procedure Read_CFG;
  83. Var F : File of CfgRec;
  84. Begin
  85.  Assign(F,CFGPath);
  86.  Reset(F);
  87.  if IOResult<>0 then Exit;
  88.  Read(F,Default);
  89.  if IOResult<>0 then ;
  90.  Close(F);
  91.  if IOResult<>0 then ;
  92. End;
  93.  
  94. Procedure Write_CFG;
  95. Var F : File of CfgRec;
  96. Begin
  97.  With AskWindow Do
  98.   Begin
  99.    Init;
  100.    AddTitle(' Setup ');
  101.    AddLine('^Saving current setup to :');
  102.    AddLine(CenterStr(Copy(CFGPath,1,38),40));
  103.    ShowMessage;
  104.   End;
  105.  
  106.  Assign(F,CFGPath);
  107.  Rewrite(F);
  108.  if IOResult<>0 then Exit;
  109.  Write(F,Default);
  110.  if IOResult<>0 then ;
  111.  Close(F);
  112.  if IOResult<>0 then ;
  113.  AskWindow.Done;
  114. End;
  115.  
  116. Procedure LookUpStr;
  117. Var S : String;
  118.     P : Byte;
  119. Begin
  120.  SearchStr := '';
  121.  S := Screen.ReadScreenLn(YPosition);
  122.  P := XPosition;
  123.  
  124.  if S[P]<>' ' then
  125.   Begin
  126.    Repeat
  127.     Dec(P);
  128.    Until Not (S[P] in ['A'..'z',#128..#165]);
  129.   End Else Begin
  130.             While (P>1) And Not (S[P] in ['A'..'z',#128..#165]) Do Dec(P);
  131.             While (P>1) And (S[P] in ['A'..'z',#128..#165]) Do Dec(P);
  132.            End;
  133.  Inc(P);
  134.  Repeat
  135.   SearchStr := SearchStr + S[P];
  136.   Inc(P);
  137.  Until Not (S[P] in ['A'..'z',#128..#165]) Or (P>Succ(MaxCols));
  138.  
  139.  StripVar(SearchStr);
  140. End;
  141.  
  142. Procedure SaveAll;
  143. Begin
  144.  Quit := False;
  145.  InitDetect; {Check videomode first}
  146.  XPosition := WhereX; YPosition := WhereY;
  147.  With CursorShape Do
  148.   Begin
  149.    Init; { 5 cursor shapes can be saved }
  150.    PushCursor;
  151.   End;
  152.  HideCursor; { Detect.tpu }
  153.  
  154.  OrginalScr := SavePartScreen(1,1,Succ(MaxCols),Succ(MaxRows));
  155.  LookUpStr;
  156. End;
  157.  
  158. Procedure RestoreAll;
  159. Type WordRec = Record
  160.       X,Y  : Byte;
  161.      End;
  162. Begin
  163.  RestorePartScreen(OrginalScr);
  164.  DisposePartScreen(OrginalScr);
  165.  
  166.  WordRec(WindMin).X := 0;
  167.  WordRec(WindMin).Y := 0; { window to entire Scr }
  168.  WordRec(WindMax).X := Pred(MaxCols);
  169.  WordRec(WindMax).Y := Pred(MaxRows);
  170.  
  171.  GotoXY(XPosition,YPosition);
  172.  With CursorShape Do
  173.   Begin
  174.    PopCursor;
  175.    Done; { Free memory }
  176.   End;
  177. End;
  178.  
  179. Procedure HotKeys;
  180. Begin
  181.  Writeln('To activated the NG Cloon : LeftShift-F1');
  182. End;
  183.  
  184. Procedure ChangeHotKey;
  185. Var ExitCode : Char;
  186. Begin
  187.  With AskWindow Do
  188.   Begin
  189.    Init;
  190.    AddTitle(' Change Hotkey ');
  191.    AddLine('Sorry, this option isn''t available yet.');
  192.    AddLine('This is soon to come.');
  193.    AddLine('');
  194.    AddButton('Ok');
  195.    Go(ExitCode);
  196.    Done;
  197.   End;
  198. End;
  199.  
  200.  
  201. Procedure UnInstallHelp;
  202. Var ExitCode : Char;
  203. Begin
  204.  With AskWindow Do
  205.   Begin
  206.    Init;
  207.    AddTitle(' Uninstall ');
  208.    AddLine('Do you wish to remove HELP');
  209.    AddLine('from memory ?');
  210.    AddLine('');
  211.    AddButton('Yes');
  212.    AddButton('No');
  213.    Go(ExitCode);
  214.    Done;
  215.    if ExitCode=#27 then Exit;
  216.    if ButtonNum=1 then
  217.     Begin
  218. {$IFDEF TSR}
  219.      if UnInstall<>0 then
  220.       Begin
  221.        Init;
  222.        AddTitle(' Error ');
  223.        AddLine('Cann''t remove HELP from memory.');
  224.        AddLine('Other program loaded after HELP.');
  225.        AddLine('');
  226.        AddButton('Ok');
  227.        Go(ExitCode);
  228.        Done;
  229.        Exit;
  230.       End Else Begin
  231.                 CloseGuide;
  232.  
  233.                 RestoreAll;
  234.                 StopPrg;
  235.                End;
  236. {$ELSE}
  237.      Halt;
  238. {$ENDIF}
  239.     End;
  240.   End;
  241. End;
  242.  
  243.  
  244.  
  245.  
  246. End.